package com.miyake.loveviewweb.client.explorer;

import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.TreeItem;
import com.miyake.loveviewweb.shared.model.ChartModel;
import com.miyake.loveviewweb.shared.model.DataModel;
import com.miyake.loveviewweb.shared.model.FolderModel;

public class TreeItemCreator {
    public TreeItem getTreeItem() {
        return treeItem;
    }
    private TreeItem treeItem;
    public TreeItemCreator(String name) {
        treeItem = new TreeItem(name);
    }
    public TreeItemCreator(ImageResource image, FolderModel folder) {
        treeItem = new TreeItem(AbstractImagePrototype.create(image).getHTML() + " " + folder.getFolderName());
        treeItem.setUserObject(folder.getKey());
    }
    
    public TreeItemCreator(ImageResource image, DataModel data) {
        treeItem = new TreeItem(AbstractImagePrototype.create(image).getHTML() + " " + data.getName());
        treeItem.setUserObject(data.getKey());
    }    
    
    public TreeItemCreator(ImageResource image, ChartModel chart) {
        treeItem = new TreeItem(AbstractImagePrototype.create(image).getHTML() + " " + chart.getName());
        treeItem.setUserObject(chart.getKey());
    }  
}
